﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="MokaResponse", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MokaResponse))]
    public class MokaResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMokaResponse clazz;
        
        public MokaResponseSerializer(IMokaResponse clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Message");
            if (clazz.Message!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Message))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Code");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Code))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "Message")) {
                goto Message;
            }
            else {
                if ((Reader.LocalName == "Code")) {
                    goto Code;
                }
                else {
                    return;
                }
            }
        Message:
            if ((Reader.IsElementNil() == false)) {
                clazz.Message = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Message")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        Code:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>MokaResponse>Code");
            }
            clazz.Code = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("Code")).Value;
            goto START;
        }
    }
}
